using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UI_Inventory : MonoBehaviour
{

    [SerializeField] private UI_ItemSlotParent inventoryParent;
    [SerializeField] private UI_EquipmentSlotParent equipmentSlotParent;
    private Inventory_Player inventory;

    private void Awake()
    {
        inventory = FindObjectOfType<Inventory_Player>();
        inventoryParent.UpdateSlot(inventory.itemList);
    }
    private void OnEnable()
    {
        inventory.OnInventoryChange += UpdateUI;
        UpdateUI();
    }
    private void OnDisable()
    {
        inventory.OnInventoryChange -= UpdateUI;
    }
    public void UpdateUI()
    {
        UpdateAllEquipmentSlot();
        inventoryParent.UpdateSlot(inventory.itemList);
    }
    public void UpdateAllEquipmentSlot()
    {
        List<Inventory_EquipmentSlot> equipmentSlots = inventory.equipList;

        equipmentSlotParent.UpdateEquipmentSlot(equipmentSlots);
    }
}
